package com.woniu.common.utils;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * packageName com.woniu.common.utils
 *
 * @author zxyang3636
 * @version JDK 8
 * @className GetManageUserNickName
 * @date 2024/8/8
 * @description TODO
 */
public class GetManageUserNickName {
    public static String getUserName() throws Exception {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        String jwt = request.getHeader("token");
        Map userInfo = (Map) JWTUtil.getUserInfo(jwt).get("zyManage");
        String nickname = (String) userInfo.get("manageNickName");
        return nickname;
    }
}
